<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../Templates/SaleLeadTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    
    <ui:define name="content">
        <f:view beforePhase="#{addPOWithoutSaleLead.initView}">
          <h:form>
            <p:panel id="panel" header="Add New Purchase Order"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                    <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus> 
            
                <p:messages /> 
    
                <h:panelGrid columns="3" cellpadding="10"> 
                    
                    <h:outputLabel for="name" style="font-weight: bold" value="Name: " /> 
                    <p:inputText value="#{addPOWithoutSaleLead.name}" required="true" label="Sale Lead Name" requiredMessage="Sale Lead Name is required." id="name"> 
                        
                    </p:inputText> 
                    <p:message for="name" /> 
                    
                    <h:outputLabel for="NRIC" style="font-weight: bold" value="NRIC: " /> 
                    <p:inputText required="true" label="NRIC" requiredMessage="NRIC is required." id="NRIC" value="#{addPOWithoutSaleLead.NRIC}"> 
                        
                    </p:inputText> 
                    <p:message for="NRIC" /> 
 
                    <h:outputLabel for="email" style="font-weight: bold" value="Email: " /> 
                    <p:inputText required="true" label="email" requiredMessage="Email is required." id="email" value="#{addPOWithoutSaleLead.email}"> 
                        
                    </p:inputText> 
                    <p:message for="email" /> 
                    
                    <h:outputLabel for="address" style="font-weight: bold" value="address: " /> 
                    <p:inputText required="true" label="address" requiredMessage="Address is required." id="address" value="#{addPOWithoutSaleLead.address}"> 
                        
                    </p:inputText> 
                    <p:message for="address" /> 
                    
                    <h:outputLabel for="contactNumber" style="font-weight: bold" value="Contact Number: " /> 
                    <p:inputText required="true" label="contactNumber" requiredMessage="Contact Number is required." id="contactNumber" value="#{addPOWithoutSaleLead.contactNumber}"> 
                        
                    </p:inputText> 
                    <p:message for="contactNumber" /> 
 
                    <h:outputLabel for="customerType" style="font-weight: bold" value="Customer Type: " /> 
                    <p:inputText required="true" label="customerType" requiredMessage="Customer Type is required." id="customerType" value="#{addPOWithoutSaleLead.customerType}"> 
                        
                    </p:inputText> 
                    <p:message for="customerType" />
                    
                </h:panelGrid>
                    
                    <p:dataTable var="lineItem" value="#{addPOWithoutSaleLead.lineItems}"
                             dynamic="true" paginator="true" emptyMessage="No Product Type">
                        <p:column sortBy="#{lineItem.product.productType}">
                            <f:facet name="header">
                                <h:outputText value="Product Type"/>
                            </f:facet>
                            <h:outputText value="#{lineItem.product.productType}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Quantity"/>
                            </f:facet>
                            <h:inputText value="#{lineItem.lineItemQuantity}" />
                            </p:column>
                        
                        </p:dataTable>
                    
                    <p:commandButton id="btn" value="Save New Purchase Order" update="panel" actionListener="#{addPOWithoutSaleLead.saveNewPurchaseOrder(event)}" ajax="false" />
            </p:panel>
        </h:form>
      </f:view>
    </ui:define>
</ui:composition>

